package anni.anews.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import anni.core.domain.NamedEntityBean;

import anni.core.grid.LongGridBean;

import org.hibernate.annotations.GenericGenerator;


/**
 * NewsTag generated by Lingo.
 *
 * @author Lingo
 * @since 2007年08月16日 下午 23时13分00秒31
 */
@Entity
@Table(name = "A_NEWS_TAG")
public class NewsTag extends LongGridBean implements NamedEntityBean {
    /** * serial. */
    static final long serialVersionUID = 0L;

    /** * id. */
    private Long id;

    /** * name. */
    private String name;

    /** * theSort. */
    private Integer theSort;

    /** * newses. */
    private Set<News> newses = new HashSet<News>(0);

    /** * 构造方法. */
    public NewsTag() {
    }

    /** * @return id. */
    @GenericGenerator(name = "generator", strategy = "increment")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "ID", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    /** * @param id id. */
    public void setId(Long id) {
        this.id = id;
    }

    /** * @return name. */
    @Column(name = "NAME", length = 50, unique = true, nullable = false)
    public String getName() {
        return name;
    }

    /** * @param name name. */
    public void setName(String name) {
        this.name = name;
    }

    /** * @return theSort. */
    @Column(name = "THE_SORT")
    public Integer getTheSort() {
        return theSort;
    }

    /** * @param theSort theSort. */
    public void setTheSort(Integer theSort) {
        this.theSort = theSort;
    }

    /** * @return newses. */
    @ManyToMany(cascade =  {
        CascadeType.PERSIST, CascadeType.MERGE}
    , fetch = FetchType.LAZY)
    @JoinTable(name = "A_NEWS_NEWSTAG", joinColumns =  {
        @JoinColumn(name = "NEWSTAG_ID")
    }
    , inverseJoinColumns =  {
        @JoinColumn(name = "NEWS_ID")
    }
    )
    public Set<News> getNewses() {
        return newses;
    }

    /** * @param newses newses. */
    public void setNewses(Set<News> newses) {
        this.newses = newses;
    }
}
